﻿using System;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using LFloatMath.Math;

namespace IQIGame.Onigao.Logic
{
    public class SkillEffective_ReplaceTargetSelect : SkillEffective
    {
        public override void OnInitialize(SkillEffectiveData rData)
        {
            base.OnInitialize(rData);
            if (rData.effectiveConfig.customConfig is SkillEffective_ReplaceTargetSelect_ConfigData rConfig)
            {
                var rSelect = TargetSelectFactory.CreateTargetSelectBySkill(rData.skill, rConfig.select);
                rData.runtimeData = rSelect;
            }
        }

        protected override ISerializeCustomPOD OnExecute(SkillEffectiveData data, Unit target, SkillEffectiveContext context, int effectiveIndex, out SkillEffectiveResponse startResp)
        {
            startResp = null;
            if (data.effectiveConfig.customConfig is SkillEffective_RepalceSkillType_ConfigData rConfig && context.param is SkillPart rTargetPart)
            {
                rTargetPart.tempSelect = data.runtimeData as TargetSelect;
            }

            return null;
        }

#if UNITY_EDITOR
        public override string ToString(SkillCustomConfig config)
        {
            return "提换buff的释放者为目标单位";
        }
#endif
    }
}